<?php
require_once("../../../config.inc.php");
$isReloadable = false;
require_once("../../../app/_inc/include.php");

$errMsg = "";
if(sxREQUEST("reqtype") == "save"){
	$errMsg .= domainValueIns();	
}
if(sxREQ("dom")!='') {
	$_REQUEST['domain'] = sxREQ("dom");
	$_REQUEST['sequence'] = 10;
}

$aOpz = array("tit2"=>_t("Nuovo valore del Domain"), "isReloadable"=>$isReloadable);
echo(headerHTML($aOpz));
?>
<script language="JavaScript" type="text/javascript" src="../../_jsc/form.js"></script>  
<script language="JavaScript" type="text/javascript">
</script>
  
<?php
echo(bodyHTML($aOpz));
//output comandi
echo("<table class=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
//form inserimento dati
echo("<form name=\"objFrm\" id=\"objFrm\" action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">");
echo("<input type=\"hidden\" name=\"reqtype\" id=\"reqtype\" value=\"save\">");
echo("<input type=\"hidden\" name=\"xsn\" id=\"xsn\" value=\"".XSN."\">");

$aCmd = array("insRel"=>array("pag"=>"javascript:document.objFrm.submit()",
										"title"=>_t("Salva i valori del Domain"),
										"text"=>_t("salva"),
										"perm"=>"newdom"),
					"back"=>array("pag"=>$objUser->getHistory(0, false),
										"title"=>"cancel",
										"text"=>"cancel")
					);
echo(commandsHTML($aCmd));	
echo("<table class=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
echo("<tr>" .
		"<td class=\"titl01\" colspan=\"2\">"._t("Valori Domain")."</td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"labl01\" width=\"25%\">"._t("Domain")."</td>" .
		"<td class=\"text01\" width=\"75%\">" .sxREQUEST('domain').
		"<input class=\"inpt01\" type=\"hidden\" name=\"domain\" id=\"domain\" value=\"".sxREQUEST('domain')."\"></td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"labl01\">"._t("valore Domain")." (*)</td>" .
		"<td class=\"text01\">".
		"<input type=\"text\" name=\"value\" id=\"value\" value=\"".sxHE(sxREQUEST('value'))."\" class='inpt01' size='32' maxlength='32'></td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"labl01\">"._t("description")." (*)</td>" .
		"<td class=\"text01\">" .
		"<input class=\"inpt01\" type=\"text\" name=\"description\" id=\"description\" value=\"".sxHE(sxREQUEST('description'))."\" maxlength=\"80\" size=\"60\"></td>" .
	"</tr>\n");
echo("<tr>" .
		"<td class=\"labl01\">"._t("sequenza")." (*)</td>" .
		"<td class=\"text01\">" .
		"<input class=\"inpt01\" type=\"text\" name=\"sequence\" id=\"sequence\" value=\"".sxHE(sxREQUEST('sequence'))."\" size=\"20\"></td>" .
	"</tr>\n");
echo("<tr>" .
	"<td class=\"labl01\">"._t("note")."</td>" .
	"<td class=\"text01\">" .
	"<textarea class=\"inpt01\" name=\"note\" id=\"note\" cols=\"80\" rows=\"5\">".sxHE(sxREQUEST('note'))."</textarea></td>" .
"</tr>\n");

echo(commandsHTML($aCmd));
echo("</form>\n");
echo("</td>\n</tr>\n</table>\n");
echo(footerHTML());

function domainValueIns(){
	global $objSDAO, $objUser;
	$errMsg = "";
	if(trim(sxREQUEST("value")) == "")
		$errMsg .= _t("Il valore @ obbligatorio")."<br>";
	if(sxREQUEST("description") == "")
		$errMsg .= _t("La description &egrave; obbligatoria")."<br>";
	if(ereg("[^0-9]",sxREQUEST("sequence")))
		$errMsg .= _t("La sequenza deve essere un numerico")."<br>";
	if($errMsg != "")
		return $errMsg;
	$sSQL = "INSERT INTO domain_value (domain,value,description,sequence,note) VALUES (" .
			" '".sxRAS("domain")."', '".sxRAS("value")."', '".sxRAS("description")."', " .
			sxRAS("sequence").", '".sxRAS("note")."')";
	$objSDAO->exec($sSQL);
	serverRedir($objUser->getHistory(0));
	return '???';
}

?>
